package imvu.rbox.object
{
	import anshe.object.ExTextField;
	
	import flash.display.Sprite;
	
	import imvu.rbox.struct.CGamePlayerInfo;

	public class ScoreLines extends Sprite
	{
		public var txtID:ExTextField;			//	排名
		public var txtUserName:ExTextField;		//	用户名
		public var txtUserScore:ExTextField;	//	用户成绩
		public var txtAdd:ExTextField;			//	添加的成绩
		public var mcFlag:Sprite;				//	死亡标识
		
		public function ScoreLines()
		{
			this.cacheAsBitmap = true;
			this.txtAdd.Disabled();
			this.txtID.Disabled();
			this.txtUserName.Disabled();
			this.txtUserScore.Disabled();			
			this.mcFlag.mouseChildren = this.mcFlag.mouseEnabled = false;
			
			InitBase();
		}
		
		public function InitBase():void
		{
			this.id = 0;
			this.info = null;
			this.color = 0xFFFFFF;	 
		}
		
		public function set color(col:uint):void
		{
			this.txtUserName.color = col;
			this.txtUserScore.color = col;
			this.txtAdd.color = col;
			this.txtID.color = col;
		}
		
		public function set bold(flag:Boolean):void
		{
			this.txtUserName.isBord = flag;
			this.txtAdd.isBord = flag;
			this.txtUserScore.isBord = flag;
			this.txtID.isBord = flag;
		}
		
		public function set id(num:Number):void
		{
			this.txtID.text = (num > 0) ? "." + num + "." : "";
		}
		
		public function get id():Number
		{
			return Number(this.txtID.text);
		}
		
		public function set info(uInfo:CGamePlayerInfo):void
		{
			if(uInfo)
			{
				trace("getUserInfo:" + uInfo.userName + ":" + uInfo.addScore + " : " + uInfo.userScore);
				
				this.txtUserName.text = uInfo.userNick;
				this.txtUserScore.text = "" + uInfo.userScore;
				if(uInfo.addScore > 0)
				{
					this.txtAdd.text = "+" + uInfo.addScore;
				}
				else
				{
					this.txtAdd.text = "";
				}
				this.mcFlag.visible = uInfo.isDead;
			}
			else
			{
				this.txtAdd.text = "";
				this.txtUserName.text = "";
				this.txtUserScore.text = "";
				this.mcFlag.visible = false;
			}
		}
	}
}